import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { PurchaseInvoiceVO, PurchaseInvoiceForm, PurchaseInvoiceQuery } from '@/api/finance/purchaseInvoice/types';

/**
 * 查询采购发票列表
 * @param query
 * @returns {*}
 */

export const listPurchaseInvoice = (query?: PurchaseInvoiceQuery): AxiosPromise<PurchaseInvoiceVO[]> => {
  return request({
    url: '/finance/purchaseInvoice/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询采购发票详细
 * @param id
 */
export const getPurchaseInvoice = (id: string | number): AxiosPromise<PurchaseInvoiceVO> => {
  return request({
    url: '/finance/purchaseInvoice/' + id,
    method: 'get'
  });
};

/**
 * 新增采购发票
 * @param data
 */
export const addPurchaseInvoice = (data: PurchaseInvoiceForm) => {
  return request({
    url: '/finance/purchaseInvoice',
    method: 'post',
    data: data
  });
};

/**
 * 修改采购发票
 * @param data
 */
export const updatePurchaseInvoice = (data: PurchaseInvoiceForm) => {
  return request({
    url: '/finance/purchaseInvoice',
    method: 'put',
    data: data
  });
};

/**
 * 删除采购发票
 * @param id
 */
export const delPurchaseInvoice = (id: string | number | Array<string | number>) => {
  return request({
    url: '/finance/purchaseInvoice/' + id,
    method: 'delete'
  });
};
